using B.S.Medical.Api.Write.Application.Command.Doctor;
using B.S.Medical.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Medical.Api.Write.Controllers.Doc
{
    /// <summary>
    /// 医生控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DoctorController : ControllerBase
    {
        private readonly IMediator _mediator;

        /// <summary>
        /// 构造函数
        /// </summary>
        public DoctorController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 新增医生
        /// </summary>
        /// <param name="command">医生新增命令</param>
        /// <returns>返回结果</returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddDoctor(CreateDoctorCommand command)
        {
            if (command == null)
            {
                return new ApiResult<int>
                {
                    Code = ApiEnum.Fail,
                    Msg = "参数不能为空!"
                };
            }

            return await _mediator.Send(command);
        }

        /// <summary>
        /// 更新医生状态
        /// </summary>
        /// <param name="command">更新医生状态命令</param>
        /// <returns>返回结果</returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateDoctorStatus(UpdateDoctorStatusCommand command)
        {
            if (command == null)
            {
                return new ApiResult<int>
                {
                    Code = ApiEnum.Fail,
                    Msg = "参数不能为空!"
                };
            }

            return await _mediator.Send(command);
        }
        /// <summary>
        /// 修改医生信息
        /// </summary>
        /// <param name="command">医生修改命令</param>
        /// <returns>返回结果</returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateDoctor(UpdateDoctorCommand command)
        {
            if (command == null)
            {
                return new ApiResult<int>
                {
                    Code = ApiEnum.Fail,
                    Msg = "参数不能为空!"
                };
            }
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 批量删除医生
        /// </summary>
        /// <param name="command">批量删除命令</param>
        /// <returns>返回结果</returns>
        [HttpPut]
        public Task<ApiResult<int>> BatchDeleteDoctor(BatchDeleteDoctorCommand command)
        {
            return _mediator.Send(command);
        }
    }
}